﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>阅卷</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../js/ligerui.min.js" type="text/javascript"></script>
     <script src="../Js/json2.js" type="text/javascript"></script>
     <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
     <script src="../Js/conmon.js" type="text/javascript"></script>
    <style type="text/css">
        .table{background-color:#84A0C4;border:1px solid #84A0C4;font-size:10pt;}
        .td{background-color:#ffffff;border:1px solid #84A0C4;}
    </style>
    <script type="text/javascript">
        var C_ID = 0;
        $(function () {
            pWind = parent.window.parent.window.getWindow();
            C_ID = (pWind != null ? pWind.C_ID : 0);
            if (C_ID == 0) {
                showErrorTip("参数错误！");
                return;
            }
            $("#btnClose").click(function () { closeRefresh(false, ""); });
            //获取数据
            var params = { C_ID: C_ID, Rnd: Math.random() };
            $("#divContent").mask("数据处理中，请稍候......");
            $.getJSON('../WebServer/ExamRoom.ashx?Action=GetQATopic', params, function (data) {
                $("#divContent").unmask();
                if (data == null)
                    return;
                $.each(data, function (i, item) {
                    $("#tableQAList").append('<tr><td class="td" style="width:10%;" align="right">题&nbsp;&nbsp;&nbsp;&nbsp;目：</td><td class="td" style="padding:10px;"><label id="lblTitle' + i + '">' + item.T_TITLE + '</label></td></tr>');
                    $("#tableQAList").append('<tr><td class="td" style="width:10%;" align="right">参考答案：</td><td class="td" style="padding:10px;"><label id="lblRefAnswer' + i + '">' + item.A_ANSWER + '</label></td></tr>');
                    $("#tableQAList").append('<tr><td class="td" style="width:10%;" align="right">考生答案：</td><td class="td" style="padding:10px;"><label id="lblAnswer' + i + '">' + item.R_REPLY + '</label>' + (item.R_ID==0?'<p style="color:blue;">(此题该考生未答)</p>':'') + '</td></tr>');
                    $("#tableQAList").append('<tr><td class="td" style="width:10%;" align="right">考生得分：</td><td class="td" style="padding:10px;"><div style="float:left"><input type="text" class="l-text" onchange="CheckScore(this,' + item.S_FULLSCORE + ');" id="txtScore' + i + '" S_ID="' + item.S_ID + '" /></div><div style="float:left">&nbsp;&nbsp;<span style="color:Red">本题满分为：<label id="lblFullScore' + i + '">' + item.S_FULLSCORE + '</label>分</span></div></td></tr>');
                    $("#tableQAList").append('<tr><td style="background-color:#ffffff;" colspan="2"><p style="border-bottom:1px dashed gray;padding-top:5px;width:100%" ></p></td></tr>');
                });
                //
                $("#tableQAList :text[id^='txtScore']").each(function (i, item) {$(item).ligerSpinner({ width: 80, type: 'int' }); });
            });
        });

        //检查分数
        function CheckScore(obj, fullScore) {
            var score = parseInt(obj.value);
            if (score < 0) {
                showErrorTip("得分不能小于0");
                obj.value = "0";
                return;
            }
            if (score > fullScore) {
                showErrorTip("得分不能大于满分！");
                obj.value = fullScore;
                return;
            }
        }

        function SaveData() {
            if ($("#tableQAList :text[id^='txtScore'][value='']").length > 0) {
                showErrorTip("请填写考生得分！");
                return;
            }
            var scoreArray = new Array();
            var scoreCtrls = $("#tableQAList :text[id^='txtScore']");
            $.each(scoreCtrls, function (i, item) {
                scoreArray.push({ sheetID: parseInt($(item).attr("S_ID")), score: parseInt($(item).val()) });
            });
            $("#divContent").mask("数据处理中，请稍候......");
            var params = { C_ID: C_ID, TopicScores: JSON2.stringify(scoreArray), rnd: Math.random() };
            $.getJSON('../WebServer/ExamRoom.ashx?Action=ScoreQATopic', params, function (msgData) {
                $("#divContent").unmask();
                if (msgData == null)
                    return;
                if (msgData.IsSuccess == 1) {
                    showAlertOk("保存成功");
                    closeRefresh(false, "");
                    if (pWind) pWind.loadGrid();
                }
                else
                    showErrorTip(data.Msg);
            });
        }
    </script>
</head>
<body>
    <div id="divContent">
    <table width="100%" cellpadding="1px" cellspacing="1px" class="table" id="tableQAList">
        <tr style="height:30px">
            <td colspan="2" align="center" class="td" style="font-weight:bold;">问答题阅卷</td>
        </tr>
     </table>
    <table width="100%" cellpadding="0" cellspacing="0" style="height:100%;">
        <tr style="height:30px">
            <td  align="center">
                <input type="button" id="btnPost" value="评分" onclick="SaveData();" class="l-button" style="display:inline" />
                <input type="button" id="btnClose" value="关闭"class="l-button" style="display:inline" />
            </td>
        </tr>    
    </table>

    </div>
</body>
</html>
